﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using forum_iteration1.Forum;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels.Tcp;

namespace forum_iteration1.Network_Remoting
{
    class Server
    {
        private Forum.Forum _forum;

        public Server()
        {
            _forum = new Forum.Forum("Movies", "add");
        }

        public void addThread(Thread thread)
        {
            _forum.addThread(thread);
        }

        static void Main(string[] args)
        {
            Console.Title = "Remote Server";
            
            // create and register the channel
            TcpChannel x_channel = new TcpChannel(20172);
            ChannelServices.RegisterChannel(x_channel, false);
            // register the count server for remoting
            RemotingConfiguration.ApplicationName = "User";
            RemotingConfiguration.RegisterActivatedServiceType(typeof(User));
            
            Console.WriteLine("Press return to exit.");
            Console.ReadLine();

            x_channel.StopListening(null); 
        }
    }
}
